﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Cors;
using System.Web.Http.Description;

namespace ldhWebApi.Controller
{
    // Allow CORS for all origins. (Caution!)
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    //[EnableCors(origins: "http://www.contoso.com,http://www.example.com", headers: "accept,content-type,origin,x-my-header", methods: "get,post")]
    [RoutePrefix("api/values")]
    public class ValuesController : ApiController
    {
        // GET api/values 
        //[DeflateCompression]//using zlib compression
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5 
        //[ResponseType(typeof(Book))]
        public async Task<IHttpActionResult> Get(int id)
        {
            await Task.Delay(20);
            return Ok("value");
        }

        // POST api/values 
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5 
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5 
        public void Delete(int id)
        {
        }
    } 
}
